package cn.btks.resultintegration.rule.controller;

import cn.btks.commonserver.result.MenuSourceEnum;
import cn.btks.commonserver.result.ResultState;
import cn.btks.commonserver.result.StateInfo;
import cn.btks.commonserver.result.SystemLogEnum;
import cn.btks.commonserver.valid.SystemLog;
import cn.btks.resultintegration.rule.pojo.*;
import cn.btks.resultintegration.rule.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author lijun
 * @Date 2021/8/1 15:18
 */
@RestController
@RequestMapping("api/v1.0/resultIntegration/rule")
@Api(tags = "规则模块")
@Validated
public class EnvironmentElementRuleController {

    @Autowired
    AtmosphereRuleService atmosphereRuleService;

    @Autowired
    EcologicalSpaceRuleService ecologicalSpaceRuleService;

    @Autowired
    EnvironmentResourceRuleService environmentResourceRuleService;

    @Autowired
    EnvironmentSoilRuleService environmentSoilRuleService;

    @Autowired
    EnvironmentWaterRuleService environmentWaterRuleService;

    @Autowired
    EnvironmentWholeRuleService environmentWholeRuleService;

    @GetMapping("/atmosphereRule/findByCode/{code}")
    @ApiOperation("《大气环境管控分区》根据管控分区要素编码查询管控分区要求")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "code", value = "要素编码", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findByCode1(@PathVariable("code") String code) {
        AtmosphereRule atmosphereRule = atmosphereRuleService.findByCode(code);
        return atmosphereRule != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), atmosphereRule) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }

    @SystemLog(type = SystemLogEnum.QUERY_LOG,moduleMessage = MenuSourceEnum.MENU_RESULT)
    @GetMapping("/atmosphereRule/findPages")
    @ApiOperation("《大气环境管控分区》分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNumber", value = "当前页码", required = true, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页行数", required = true, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "division", value = "师区划", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "code", value = "编码", required = true, dataType = "string"),

            @ApiImplicitParam(paramType = "header", name = "token", value = "token", required = true, dataType = "string")
    })
    public ResultState findPages1(Integer pageNumber, Integer pageSize,String division,String code) {
        return atmosphereRuleService.findPages(pageNumber, pageSize,division , code);
    }

    @GetMapping("/ecologicalSpaceRule/findByCode/{code}")
    @ApiOperation("《生态空间管控分区》根据管控分区要素编码查询管控分区要求")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "code", value = "要素编码", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findByCode2(@PathVariable("code") String code) {
        EcologicalSpaceRule ecologicalSpaceRule = ecologicalSpaceRuleService.findByCode(code);
        return ecologicalSpaceRule != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), ecologicalSpaceRule) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }

    @SystemLog(type = SystemLogEnum.QUERY_LOG,moduleMessage = MenuSourceEnum.MENU_RESULT)
    @GetMapping("/ecologicalSpaceRule/findPages")
    @ApiOperation("《生态空间管控分区》分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNumber", value = "当前页码", required = true, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页行数", required = true, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "division", value = "师区划", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "code", value = "编码", required = true, dataType = "string"),

            @ApiImplicitParam(paramType = "header", name = "token", value = "token", required = true, dataType = "string")
    })
    public ResultState findPages2(Integer pageNumber, Integer pageSize,String division,String code) {
        return ecologicalSpaceRuleService.findPages(pageNumber, pageSize,division,code);
    }

    @GetMapping("/environmentResourceRule/findByCode/{code}")
    @ApiOperation("《自然资源管控分区》根据管控分区要素编码查询管控分区要求")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "code", value = "要素编码", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findByCode3(@PathVariable("code") String code) {
        EnvironmentResourceRule environmentResourceRule = environmentResourceRuleService.findByCode(code);
        return environmentResourceRule != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), environmentResourceRule) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }

    @SystemLog(type = SystemLogEnum.QUERY_LOG,moduleMessage = MenuSourceEnum.MENU_RESULT)
    @GetMapping("/environmentResourceRule/findPages")
    @ApiOperation("《自然资源管控分区》分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNumber", value = "当前页码", required = true, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页行数", required = true, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "division", value = "师区划", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "code", value = "编码", required = true, dataType = "string"),

            @ApiImplicitParam(paramType = "header", name = "token", value = "token", required = true, dataType = "string")
    })
    public ResultState findPages3(Integer pageNumber, Integer pageSize,String division,String code) {
        return environmentResourceRuleService.findPages(pageNumber, pageSize, division,code );
    }

    @GetMapping("/environmentSoilRule/findByCode/{code}")
    @ApiOperation("《土壤污染风险管控分区》根据管控分区要素编码查询管控分区要求")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "code", value = "要素编码", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findByCode4(@PathVariable("code") String code) {
        EnvironmentSoilRule environmentSoilRule = environmentSoilRuleService.findByCode(code);
        return environmentSoilRule != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), environmentSoilRule) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }

    @SystemLog(type = SystemLogEnum.QUERY_LOG,moduleMessage = MenuSourceEnum.MENU_RESULT)
    @GetMapping("/environmentSoilRule/findPages")
    @ApiOperation("《土壤污染风险管控分区》分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNumber", value = "当前页码", required = true, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页行数", required = true, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "division", value = "师区划", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "code", value = "编码", required = true, dataType = "string"),

            @ApiImplicitParam(paramType = "header", name = "token", value = "token", required = true, dataType = "string")
    })
    public ResultState findPages4(Integer pageNumber, Integer pageSize,String division,String code) {
        return environmentSoilRuleService.findPages(pageNumber, pageSize, division,code);
    }

    @GetMapping("/environmentWaterRule/findByCode/{code}")
    @ApiOperation("《水环境管控分区》根据管控分区要素编码查询管控分区要求")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "code", value = "要素编码", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findByCode5(@PathVariable("code") String code) {
        EnvironmentWaterRule environmentWaterRule = environmentWaterRuleService.findByCode(code);
        return environmentWaterRule != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), environmentWaterRule) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }

    @SystemLog(type = SystemLogEnum.QUERY_LOG,moduleMessage = MenuSourceEnum.MENU_RESULT)
    @GetMapping("/environmentWaterRule/findPages")
    @ApiOperation("《水环境管控分区》分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNumber", value = "当前页码", required = true, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页行数", required = true, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "division", value = "师区划", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "code", value = "编码", required = true, dataType = "string"),

            @ApiImplicitParam(paramType = "header", name = "token", value = "token", required = true, dataType = "string")
    })
    public ResultState findPages5(Integer pageNumber, Integer pageSize,String division,String code) {
        return environmentWaterRuleService.findPages(pageNumber, pageSize, division,code);
    }

    @SystemLog(type = SystemLogEnum.QUERY_LOG,moduleMessage = MenuSourceEnum.MENU_RESULT)
    @GetMapping("/environmentWholeRule/findPages")
    @ApiOperation("《区域总体管控要求》分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNumber", value = "当前页码", required = true, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页行数", required = true, dataType = "int"),

            @ApiImplicitParam(paramType = "header", name = "token", value = "token", required = true, dataType = "string")
    })
    public ResultState findPages6(Integer pageNumber, Integer pageSize) {
        return environmentWholeRuleService.findPages(pageNumber, pageSize);
    }
}
